package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.GlueBanner;
import com.ruoyi.system.mapper.GlueBannerMapper;
import com.ruoyi.system.service.IGlueBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 轮播图Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-31
 */
@Service
public class GlueBannerServiceImpl implements IGlueBannerService
{
    @Autowired
    private GlueBannerMapper glueBannerMapper;

    /**
     * 查询轮播图
     *
     * @param id 轮播图主键
     * @return 轮播图
     */
    @Override
    public GlueBanner selectGlueBannerById(Long id)
    {
        return glueBannerMapper.selectGlueBannerById(id);
    }

    /**
     * 查询轮播图列表
     *
     * @param glueBanner 轮播图
     * @return 轮播图
     */
    @Override
    public List<GlueBanner> selectGlueBannerList(GlueBanner glueBanner)
    {
        return glueBannerMapper.selectGlueBannerList(glueBanner);
    }

    /**
     * 新增轮播图
     *
     * @param glueBanner 轮播图
     * @return 结果
     */
    @Override
    public int insertGlueBanner(GlueBanner glueBanner)
    {
        glueBanner.setCreateTime(DateUtils.getNowDate());
        glueBanner.setCreateBy(SecurityUtils.getUserId().toString());
        return glueBannerMapper.insertGlueBanner(glueBanner);
    }

    /**
     * 修改轮播图
     *
     * @param glueBanner 轮播图
     * @return 结果
     */
    @Override
    public int updateGlueBanner(GlueBanner glueBanner)
    {
        glueBanner.setUpdateTime(DateUtils.getNowDate());
        return glueBannerMapper.updateGlueBanner(glueBanner);
    }

    /**
     * 批量删除轮播图
     *
     * @param ids 需要删除的轮播图主键
     * @return 结果
     */
    @Override
    public int deleteGlueBannerByIds(Long[] ids)
    {
        return glueBannerMapper.deleteGlueBannerByIds(ids);
    }

    /**
     * 删除轮播图信息
     *
     * @param id 轮播图主键
     * @return 结果
     */
    @Override
    public int deleteGlueBannerById(Long id)
    {
        return glueBannerMapper.deleteGlueBannerById(id);
    }
}
